import type { WebviewApi } from "vscode-webview";

class VSCodeApiWrapper {
  private api: WebviewApi<unknown> | undefined;

  constructor() {
    if(typeof acquireVsCodeApi === 'function') {
      this.api = acquireVsCodeApi();
    }
  }

	postMessage(message: any) {
		if(this.api) {
			this.api.postMessage(message);
		} else {
			console.log(message)
		}
	}
}

export const vscode = new VSCodeApiWrapper()